/**************************************************************************
 *         Copyright(c) 2007 by Sunplus mMedia  Technology Co., Ltd.      *
 *                                                                        *
 *  This software is copyrighted by and is the property of Sunplus mMedia *
 *  Technology Co., Ltd. All rights are reserved by Sunplus mMedia Techno-*
 *  logy Co., Ltd. This software may only be used in accordance with the  *
 *  corresponding license agreement. Any unauthorized use, duplication,   *
 *  distribution, or disclosure of this software is expressly forbidden.  *
 *                                                                        *
 *  This Copyright notice "M U S T" not be removed or modified without    *
 *  prior written consent of Sunplus mMedia Technology  Co., Ltd.         *
 *                                                                        *
 *  Sunplus mMedia Technology Co., Ltd. reserves the right to modify this *
 *  software without notice.                                              *
 *                                                                        *
 *  Sunplus mMedia Technology Co., Ltd.                                   *
 *  19-1, Innovation First Road, Science-Based Industrial Park,           *
 *  Hsin-Chu, Taiwan, R.O.C.                                              *
 *                                                                        *
 **************************************************************************/

#ifndef __SP1K_VFS_API_H__
#define __SP1K_VFS_API_H__

/** \file sp1k_vfs_api.h
 * @brief		Spca1528 file system related interface
 */

#include "sp1k_def.h"

/**************************************************************************
 *                           C O N S T A N T S                            *
 **************************************************************************/

/**************************************************************************
 *                              M A C R O S                               *
 **************************************************************************/
#ifdef SP1K_DOXY_GEN
/**
 * @fn UINT8 sp1kVfsFmt( UINT8 eraseCard )
 * @brief	To format the current storage drive
 * @param[in] eraseCard	    specify to do physical erase or not, especially nand drive
 *\n                              0: Not to do physical format.
 *\n                              1: Do physical format                               
 * @retval\n 
 *      TRUE  : format error.
 *\n    FALSE : format success                               
*/
UINT8 sp1kVfsFmt(UINT8 eraseCard);
/**
 * @fn UINT8 sp1kVfsInit( UINT8 doDOSInitial )
 * @brief	To do file system initialization
 * @param[in] doDOSInitial	To refresh file system buffer
 *\n      0: Not to do dos buffer refresh.
 *\n      1: Do dos buffer refresh, it's better to set doDOSInitial = 1.
 *\n         Because this will read all DOS related info ( such as FAT, directory ..)
 *\n         from storage to buffer.                      
 * @retval\n 
 *      TRUE  : initial error.
 *\n    FALSE : initial success                               
*/
UINT8 sp1kVfsInit( UINT8 doDOSInitial );
/**
 * @fn UINT8 sp1kVfsDel( UINT8 *name )
 * @brief	To delete a file
 * @param[in] *name	specify the target file name
 * @retval\n 
 *      TRUE  : delete error.
 *\n    FALSE : delete success                               
 * @see sp1kVfsDelAll()
*/
UINT8 sp1kVfsDel( UINT8 *name );
/**
 * @fn UINT8 sp1kVfsDelAll( UINT8 matchCond, UINT32 refCon )
 * @brief	To delete all file by match condition and reference condition
 * @param[in] matchCond	   specify the file matched condition 
 *\n          K_DOS_MatchName : file name match condition.
 *\n          K_USR_AllDcffile: match the DCF file name condition.
 * @param[in] refCon       specify the file reference condition
 *\n          For K_DOS_MatchName, refCon is file name.
 *\n          For K_USR_AllDcffile, refCon is file type ( such as JPG, AVI, WAC ..).
 * @retval\n 
 *      TRUE  : delete error.
 *\n    FALSE : delete success                               
 * @see sp1kVfsDel()
*/
UINT8 sp1kVfsDelAll( UINT8 matchCond, UINT32 refCon );
/**
 * @fn UINT8 sp1kDcfInit( void )
 * @brief	To do DCF initialization
 * @retval\n 
 *      TRUE  : initial error.
 *\n    FALSE : initial success                               
*/
UINT32 sp1kClusterSizeGet( void );
/**
 * @fn UINT32 sp1kClusterSizeGet( void )
 * @brief	To get the cluster size of disk
 * @retval\n 
 *\n                                  
*/
UINT8 sp1kDcfInit( void );
/**
 * @fn void sp1kDcfFileTypeEnable(UINT8 type, UINT8 en)
 * @brief	Enable or disable file types. All file types are enable by default.
 *\n        Invoked before dos initialize if needed.
 * @param[in] type specify the file type
 *\n          DCF_FILE_TYPE_ALL(0) : for all types.
 *\n          DCF_FILE_TYPE_JPG : for JPG file type.
 *\n          DCF_FILE_TYPE_AVI : for AVI file type.
 *\n          DCF_FILE_TYPE_WAV : for WAV file type.
 * @param[in] en   enable or disable
 *\n          0 : disable the file type specified by the param of type.
 *\n          1 : enable the file type specified by the param of type.
 * @retval none
 * @see dcfFileType_t
*/
void sp1kDcfFileTypeEnable(UINT8 type, UINT8 en);

/**
 * @fn void sp1kDcfUsrFileBaseNameUpdate(UINT8 *name)
 * @brief	Modify file base name.
 * @param[in] name specify the name base name, should be DCF file name free characters.
 * @retval none
 * @see none
*/
void sp1kDcfUsrFileBaseNameUpdate(UINT8 *name);

#else
#include "Dosusr.h"
#include "doslink.h"
#include "Storage.h"
#include "Cardui.h"
#include "Cardvar.h"

typedef enum dcfFileType_e{
    DCF_FILE_TYPE_ALL = 0,
    DCF_FILE_TYPE_JPG,
    DCF_FILE_TYPE_AVI,
    DCF_FILE_TYPE_WAV,
    DCF_FILE_TYPE_MAX
}dcfFileType_t;

#define sp1kVfsFmt           STORAGE_Format
#define sp1kVfsInit          STORAGE_Initialize
#define sp1kVfsDel           File_Delete
#define sp1kVfsDelAll        File_DeleteAllFile
#define sp1kDcfInit          USR_FileInitialize
#define sp1kClusterSizeGet   DOS_ClusterSizeGet
#define sp1kDcfFileTypeEnable   USR_DcfFileTypeEnable
#define sp1kDcfUsrFileBaseNameUpdate USR_UpdateUsrFileBaseName
#endif
/**************************************************************************
 *                          D A T A    T Y P E S                          *
 **************************************************************************/

/**************************************************************************
 *                         G L O B A L    D A T A                         *
 **************************************************************************/

/**************************************************************************
 *                 E X T E R N A L    R E F E R E N C E S                 *
 **************************************************************************/

/**************************************************************************
 *               F U N C T I O N    D E C L A R A T I O N S               *
 **************************************************************************/
UINT8 sp1kDosRamBufSet(UINT32 size);

#endif 

